home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: Mar 14, 1997
- //
- //
- // Description:
- // This script performs loft action on the selection list.
- //
-
-
- proc addOneToLoft( string $loft, int $index, string $curve, int $range )
- {
- string $node[] = `duplicateCurve -rn $range -o false $curve`;
- if( size($node) > 0 ) {
- if( "nurbsCurve" == `nodeType $node[0]`) {
- connectAttr ($curve + ".ws") ($loft + ".ic[" + $index + "]");
- }
- else {
- connectAttr ($node[0] + ".oc") ($loft + ".ic[" + $index + "]");
- }
- }
- }
-
- proc int addToLoft( string $lofted, string $curves[], int $range )
- {
- if( size($curves) < 1 ) return false;
-
- string $hst[] = `listHistory -gl true -pdo true -lf true -f false $lofted `;
- int $i, $n = size($hst);
- if( $n < 1 ) return false;
-
- string $hist[];
-
- // tokenize && append.
- //
- for( $i = 0 ; $i < $n ; $i++ ) {
- string $tmp[] ;
- tokenize( $hst[$i], "|", $tmp );
- int $l = size($tmp);
- int $len = size($hist) ;
- int $j ;
- for( $j = 0 ; $j < $l ; $j++ ) {
- $hist[$len+$j] = $tmp[$j] ;
- }
- }
-
- string $loft = "";
-
- // look for the first node which is of type "loft".
- //
- $n = size($hist) ;
- for( $i=0; $i<$n; $i+=1 ) {
- string $name = $hist[$i] ;
- if( "loft" == `nodeType $name` ) {
- $loft = $name;
- break;
- }
- }
-
- if( "" == $loft ) return false;
-
- int $cntr = eval( "getAttr -s " + $loft + ".ic" );
- $n = size($curves);
- for( $i=0; $i<$n; $i+=1 ) {
- addOneToLoft( $loft, $cntr, $curves[$i], $range );
- $cntr += 1;
- }
-
- return true;
- }
-
- global proc doPerformLoft( string $version, string $args[] )
- {
-
- if( 8 != size($args)) {
- error( "Incorrect number of arguments to doPerformLoft" );
- return;
- }
-
- int $history = $args[0];
- int $uniform = $args[1];
- int $autoReverse = $args[2];
- int $close = $args[3];
- int $degree = $args[4];
- int $spans = $args[5];
- int $range = $args[6];
- int $polys = $args[7];
-
- // Get a list of each type of acceptable object type -
- // curves, and curves-on-surface.
- //
- global int $gSelectNurbsCurvesBit;
- global int $gSelectIsoparmsBit;
- global int $gSelectSurfaceEdgeBit;
- global int $gSelectCurvesOnSurfacesBit;
- global int $gSelectMeshEdge;
-
- global int $gSelectNurbsSurfacesBit;
- global int $gSelectMeshesBit;
-
- string $curves[] = `filterExpand -ex true -sm $gSelectMeshEdge -sm $gSelectNurbsCurvesBit -sm $gSelectIsoparmsBit -sm $gSelectSurfaceEdgeBit -sm $gSelectCurvesOnSurfacesBit`;
- string $lofted[] = `filterExpand -ex true -sm $gSelectNurbsSurfacesBit -sm $gSelectMeshesBit`;
-
- int $added = false;
- if( 1 == size($lofted) ) {
- $added = addToLoft( $lofted[0], $curves, $range );
- if( $added ) {
- select -r $lofted[0];
- return;
- }
- }
-
- // Execute loft on all active curves.
- //
- int $i, $n;
- $n = size($curves);
- if( $n > 1 ) {
- $cmd = "loft" + " -ch " + $history +
- " -u " + $uniform+
- " -c " + $close +
- " -ar " + $autoReverse +
- " -d " + $degree +
- " -ss " + $spans +
- " -rn " + $range +
- " -po " + $polys +
- " -rsn true";
-
- for( $i=0; $i<$n; $i+=1 ) {
- $cmd = $cmd + " \"" + $curves[$i] + "\"";
- }
-
- string $result[] = evalEcho($cmd);
-
- if( 0 == size($result) ) {
- warning("Nothing was selected to loft. You must select curves.");
- }
- else {
- // Select all the results
- //
- select -cl;
- int $len = size($result) ;
- for( $i = 0 ; $i < $len ; $i++ ) {
- if( $i == 0 ) select -r $result[$i] ;
- else select -add $result[$i] ;
- }
- }
- }
- else {
- if( !`optionVar -q modelWithToolLoft` ) {
- error("Invalid selection. Need at least two curves.");
- }
- }
- }
-
-